<?php
/**
 * 会员操作日志记录管理
 *
 * @version        $Id: member_operations.php 1 11:24 2010年7月20日Z tianya $
 * @package        DedeCMS.Administrator
 * @copyright      Copyright (c) 2007 - 2010, DesDev, Inc.
 * @license        http://help.dedecms.com/usersguide/license.html
 * @link           http://www.dedecms.com
 */
require_once(dirname(__FILE__)."/config.php");
CheckPurview('member_Operations');
setcookie("ENV_GOBACK_URL",$dedeNowurl,time()+3600,"/");
require_once(DEDEINC.'/datalistcp.class.php');

if($dopost=="lock"){
	
	$row = $dsql->GetOne("SELECT glock FROM `#@__member_operation` WHERE buyid='$buyid' ");
	$glock=($row['glock']==1) ? 0 : 1;	
	$query = "UPDATE `#@__member_operation` SET glock = '$glock' WHERE buyid = '$buyid'";
	$dsql->ExecuteNoneQuery($query);
	ShowMsg("操作成功！",'member_operations.php',0,8);
	 exit();
	
}


if(empty($buyid)){$addsql = " WHERE 1 ";}else{$addsql = " WHERE buyid='$buyid'";}
if(isset($sta)) $addsql .= " AND sta='$sta' ";
if(!empty($product)) $addsql .= " AND product='$product' ";	
$sql = "SELECT * FROM `#@__member_operation` $addsql and (vip=1 or money=0) ORDER BY aid DESC";
$dlist = new DataListCP();

//设定每页显示记录数（默认25条）
$dlist->pageSize = 25;
$dlist->SetParameter("buyid",$buyid);
if(isset($sta)) $dlist->SetParameter("sta",$sta);

$dlist->dsql->SetQuery("SELECT * FROM #@__moneycard_type ");
$dlist->dsql->Execute('ts');
while($rw = $dlist->dsql->GetArray('ts'))
{
    $TypeNames[$rw['tid']] = $rw['pname'];
}
$tplfile = DEDEADMIN."/templets/member_operations_down.htm";

//这两句的顺序不能更换
$dlist->SetTemplate($tplfile);      //载入模板
$dlist->SetSource($sql);            //设定查询SQL
$dlist->Display();                  //显示

function GetMemberID($mid)
{
    global $dsql;
    if($mid==0)
    {
        return '0';
    }
    $row = $dsql->GetOne("SELECT userid FROM #@__member WHERE mid='$mid' ");
    if(is_array($row))
    {
        return "<a href='member_view.php?id={$mid}'>".$row['userid']."</a>";
    }
    else
    {
        return '0';
    }
}

function GetPType($tname)
{
    if($tname=='card') return '点数卡';
    else if($tname=='archive') return '购买模板';
    else if($tname=='stc') return '兑换金币';		else if($tname=='mb') return '购买定制';else if($tname=='shouyi') return '售出模板';else if($tname=='sell') return '售出定制';
    else return '会员升级';
}

function GetSta($sta)
{
    if($sta==0)
    {
        return '<font color=red>未付款</font>';
    }
    else if($sta==1)
    {
        return '<font color=blue>预付款已付</font>';
    }
	else if($sta==3)
    {
        return '<font color=blue>等待支付余款</font>';
    }
    else
    {
        return '<font color=green>已完成</font>';
    }
}
function Glock($c)
{
    if($c==0)
    {
        return '<font color=green>冻结</font>';
    }else{
        return '<font color=red>解冻</font>';
    }
}